package fi.hut.soberit.agilefant.reporting.security;

import java.util.ArrayList;
import java.util.Collection;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.GrantedAuthorityImpl;

import fi.hut.soberit.agilefant.model.export.User;

public class AgilefantAuthenticationToken implements Authentication {
	private static final long serialVersionUID = -1191414510008788125L;

	private Object principal;
	private Object credentials;
	private User agilefantUser;
	private Collection<GrantedAuthority> authorities;

	public AgilefantAuthenticationToken(Object principal, Object credentials,
			User agilefantUser) {
		this.principal = principal;
		this.credentials = credentials;
		this.agilefantUser = agilefantUser;
		this.authorities = new ArrayList<GrantedAuthority>();
		this.authorities.add(new GrantedAuthorityImpl("ROLE_USER"));
	}

	public Collection<GrantedAuthority> getAuthorities() {
		return this.authorities;
	}

	public Object getCredentials() {
		return this.credentials;
	}

	public Object getDetails() {
		return this.agilefantUser;
	}

	public Object getPrincipal() {
		return this.principal;
	}

	public boolean isAuthenticated() {
		return true;
	}

	public void setAuthenticated(boolean arg0) throws IllegalArgumentException {
		throw new IllegalArgumentException("Not supported.");

	}

	public String getName() {
		return (String) this.getPrincipal();
	}

}
